/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef VMTYPES_H_
#define VMTYPES_H_

#include "opcodes.h"
#include "../types.h"

#include <corelib/ucs/ustring.h>
#include <corelib/types.h>

namespace paper{

class object;

// union with variable value types
typedef union{
    // language values
    // string value
    corelib::ustring *_s;
    // real value
    corelib::real32 _r;
    // integer value
    corelib::int32 _i;
    // object pointer
    object *_o;

    // virtual machine values
    // uint32 value
    corelib::uint32 _plain;
    // void pointer
    corelib::vptr _vp;
} __register;

INLINE corelib::int32 &reginteger( __register &reg ){
	return reg._i;
}

INLINE corelib::int32 reginteger( const __register &reg ){
	return reg._i;
}

INLINE corelib::real32 &regreal( __register &reg ){
	return reg._r;
}

INLINE corelib::real32 regreal( const __register &reg ){
	return reg._r;
}

INLINE corelib::ustring* &regstring( __register &reg ){
	return reg._s;
}

INLINE corelib::ustring* regstring( const __register &reg ){
	return reg._s;
}

INLINE object* &regobject( __register &reg ){
	return reg._o;
}

INLINE object* regobject( const __register &reg ){
	return reg._o;
}

}; // namespace paper;

#endif // VMTYPES_H_
